***Dynata Survey
***Implemented 8/20/20 - 8/25/20

*Use data file: Dynata2RepData.dta

***Experimental Condition
tab KevinExp
gen terror=.
replace terror=0 if KevinExp=="KevinControl"
replace terror=1 if KevinExp=="KevinIF"
replace terror=2 if KevinExp=="KevinWN"
tab terror
label define terror 0 "Control" 1 "Islamic Fundamentalist" 2 "White Nationalist"
label values terror terror
tab terror

***************
*Demographics**
***************

*Note: tables for these recoded variables are the basis for the corresponding sample demographic information Appendix Table 1 and sample information in the Supplemental Materials

*Party
*Q174 Do you consider yourself a Republican, Democrat, or independent, or what?
*Strong Democrat  (1) 
*Democrat  (2) 
*Not very strong Democrat  (3) 
*Independent (don't lean toward either party)  (4) 
*Not very strong Republican  (5) 
*Republican  (6) 
*Strong Republican  (7) 
*Other  (99) 

tab Q174
gen party2=.
replace party2=0 if Q174==1
replace party2=0 if Q174==2
replace party2=0 if Q174==3
replace party2=1 if Q174==5
replace party2=1 if Q174==6
replace party2=1 if Q174==7
tab party2
label define party2 0 "Democrat" 1 "Republican"
label values party2 party2
tab party2

gen party7=.
replace party7=1 if Q174==1
replace party7=2 if Q174==2
replace party7=3 if Q174==3
replace party7=4 if Q174==4
replace party7=5 if Q174==5
replace party7=6 if Q174==6
replace party7=7 if Q174==7
tab party7

gen party3=.
replace party3=0 if party7==1
replace party3=0 if party7==2
replace party3=0 if party7==3
replace party3=1 if party7==4
replace party3=2 if party7==5
replace party3=2 if party7==6
replace party3=2 if party7==7
tab party3
label define party3 0 "Democrat" 1 "Independent" 2 "Republican"
label values party3 party3
tab party3

*Q182 Do you currently describe yourself as male, female, or transgender?
*Male  (1) 
*Female  (2) 
*Transgender  (4) 
*None of these  (3) 

tab Q182

gen gender3=.
replace gender3=1 if Q182==1
replace gender3=2 if Q182==2
replace gender3=3 if Q182==3
replace gender3=3 if Q182==4
tab gender3
label define gender3 1 "Male" 2 "Female" 3"Other"
label values gender3 gender3
tab gender3

gen gender2=gender3
replace gender2=. if gender3==3
tab gender2
label define gender2 1 "Male" 2 "Female"
label values gender2 gender2
tab gender2

*Education
*Q183 What is the highest level of education you have completed?
tab Q183
gen edu=Q183
tab edu
tabstat edu, stats (p50)


*Age
tab Q184
gen age=Q184
replace age=. if Q184==999
tab age
mean age

*Income
tab Q186
gen income=Q186
tab income
tabstat income, stats (p50)


*Race and ethnicity
*Q179 Are you Spanish, Hispanic, or Latino?
*Yes  (1) 
*No  (2) 
tab Q179
*Q180 If you had to choose, what would you say is your race? Check all that apply. 
*White/Caucasian  (1) 
*Black/African American  (2) 
*American Indian or Alaska Native  (3) 
*Asian/Asian-American  (4) 
*Native Hawaiian or Pacific Islander  (5) 
*Other (please specify)  (6) 
tab Q180

gen race3=.
replace race3=0 if Q179==2 & Q180=="1"
replace race3=1 if Q179==2 & Q180=="2"
replace race3=2 if Q179==1 & Q180=="1"
replace race3=2 if Q179==1 & Q180=="2"
replace race3=2 if Q180=="1,2"
replace race3=2 if Q180=="1,3"
replace race3=2 if Q180=="1,3,4"
replace race3=2 if Q180=="1,4"
replace race3=2 if Q180=="1,5"
replace race3=2 if Q180=="1,6"
replace race3=2 if Q180=="2,3"
replace race3=2 if Q180=="2,5"
replace race3=2 if Q180=="3"
replace race3=2 if Q180=="4"
replace race3=2 if Q180=="4,5"
replace race3=2 if Q180=="4,6"
replace race3=2 if Q180=="5"
replace race3=2 if Q180=="6"
tab race3
label define race3 0 "White" 1 "Black" 2 "Other"
label values race3 race3
tab race3

*Ideology
*Q175 How would you describe your political views?
tab Q175
gen ideo=Q175
tab ideo

*Q38 How serious of a threat is White Nationalism to the United States?
*Not a threat at all  (1) 
*Not a very serious threat  (2) 
*Somewhat serious threat  (3) 
*Very serious threat  (4) 

tab Q38
gen WNthreat=Q38
tab WNthreat

*Q39 How serious of a threat is Islamic Fundamentalism to the United States?
*Not a threat at all  (1) 
*Not a very serious threat  (2) 
*Somewhat serious threat  (3) 
*Very serious threat  (4) 

tab Q39
gen IFthreat=Q39
tab IFthreat

gen threatgap=IFthreat-WNthreat
tab threatgap

****Order of threat questions
tab KevinOrder
gen threatorder=.
replace threatorder=0 if KevinOrder=="KevinIFThreat|KevinWNThreat"
replace threatorder=1 if KevinOrder=="KevinWNThreat|KevinIFThreat"
tab threatorder


*Q162_15 Feeling thermometer toward white nationalists: 
tab Q162_15
gen feelwn=Q162_15


**********************
*Dependent Variabels**
**********************

****Predicting threat perceptions
*Models shown in Supplemental Materials, referenced in main text
ologit WNthreat i.party2 i.gender2 i.race3 edu age income i.threatorder if(terror==0) , robust
*outreg2 using ThreatModels.doc, replace ctitle(WN Threat Con) label 
ologit WNthreat i.party2 i.gender2 i.race3 edu age income i.threatorder i.terror, robust
*outreg2 using ThreatModels.doc, append ctitle(WN Threat Full) label 

ologit IFthreat i.party2 i.gender2 i.race3 edu age income i.threatorder if(terror==0), robust
*outreg2 using ThreatModels.doc, append ctitle(IF Threat Con) label 
ologit IFthreat i.party2 i.gender2 i.race3 edu age income i.threatorder i.terror, robust
*outreg2 using ThreatModels.doc, append ctitle(IF Threat Full) label 

regress feelwn i.party2 i.gender2 i.race3 edu age income i.threatorder if(terror==0), robust
*outreg2 using WNFTModels.doc, replace ctitle(WN FT Con) label 
regress feelwn i.party2 i.gender2 i.race3 edu age income i.threatorder i.terror, robust
*outreg2 using WNFTModels.doc, append ctitle(WN FT Full) label 


*SPEECH
*Q23 Should people suspected of terrorist involvement be banned from making public speeches?
*Q29 Should Islamic Fundamentalists suspected of terrorist involvement be banned from making public speeches?
*Q35 Should White Nationalists suspected of terrorist involvement be banned from making public speeches?
*1= yes
*0= no

tab Q23
tab Q29
tab Q35

gen speech=.
replace speech=1 if Q23==1
replace speech=1 if Q29==1
replace speech=1 if Q35==1
replace speech=0 if Q23==0
replace speech=0 if Q29==0
replace speech=0 if Q35==0
tab speech
tab speech
label define speech 0 "No" 1 "Yes"
label values speech speech
tab speech

**Info for Table 4
*Dems
tab speech terror if(party2==0), col
prtest speech if(terror==0 & party2==0 | terror==1 & party2==0), by(terror)
prtest speech if(terror==0 & party2==0 | terror==2 & party2==0), by(terror)
*Rep
tab speech terror if(party2==1), col
prtest speech if(terror==0 & party2==1 | terror==1 & party2==1), by(terror)
prtest speech if(terror==0 & party2==1 | terror==2 & party2==1), by(terror)
*Full Model for Supplementals
logit speech i.terror i.party2 i.gender2 i.race3 edu age income WNthreat IFthreat  i.terror##i.party2, robust
*outreg2 using ModelsDi.doc, replace ctitle(Ban Speech) label 
margins, dydx(i.terror) at(party2=(0 1)) vsquish
marginsplot, scheme(s1mono)  xlab(-.25 " " 0 "Democrat" 1 "Republican" 1.25 " ", ) title("Effect on Probability of Support for Banning Speech (Dynata 2)") yline(0,lpattern(dot))  xtitle("Partisanship", margin(medium)) ytitle("Effect on Probability of Support", margin(medium)) plot(,label("Islamic Fundamentalist" "White Nationalist"))
*graph export SpeechParty.pdf, replace
*Predicted Probabilities for Table 4
margins i.terror, at(party2=(0 1)) vsquish


*MONITOR
*Q21 If a person is suspected of being a terrorist, should the government be allowed to monitor their phone calls without obtaining a warrant?
*Q27 If a person is suspected of being an Islamic Fundamentalist terrorist, should the government be allowed to monitor their phone calls without obtaining a warrant?
*Q33 If a person is suspected of being a White Nationalist terrorist, should the government be allowed to monitor their phone calls without obtaining a warrant?
*1= yes
*0= no

tab Q21
tab Q27
tab Q33

gen monitor=.
replace monitor=1 if Q21==1
replace monitor=1 if Q27==1
replace monitor=1 if Q33==1
replace monitor=0 if Q21==0
replace monitor=0 if Q27==0
replace monitor=0 if Q33==0
tab monitor
label define monitor 0 "No" 1 "Yes"
label values monitor monitor
tab monitor

**Info for Table
*Dem
tab monitor terror if(party2==0), col
prtest monitor if(terror==0 & party2==0 | terror==1 & party2==0), by(terror)
prtest monitor if(terror==0 & party2==0 | terror==2 & party2==0), by(terror)
*Rep
tab monitor terror if(party2==1), col
prtest monitor if(terror==0 & party2==1 | terror==1 & party2==1), by(terror)
prtest monitor if(terror==0 & party2==1 | terror==2 & party2==1), by(terror)
*Full Model for Supplementals
logit monitor i.terror i.party2 i.gender2 i.race3 edu age income WNthreat IFthreat  i.terror##i.party2, robust
*outreg2 using ModelsDi.doc, append ctitle(Monitor) label 
margins, dydx(i.terror) at(party2=(0 1)) vsquish
marginsplot, scheme(s1mono)  xlab(-.25 " " 0 "Democrat" 1 "Republican" 1.25 " ", ) title("Effect on Probability of Support for Monitoring Phone (Dynata 2)") yline(0,lpattern(dot))  xtitle("Partisanship", margin(medium)) ytitle("Effect on Probability of Support", margin(medium)) plot(,label("Islamic Fundamentalist" "White Nationalist"))
*graph export MonitorParty.pdf, replace
*Predicted Probabilities for Table 4
margins i.terror, at(party2=(0 1)) vsquish


*SOCIAL MEDIA
*Q22 Should the government shut down social media accounts belonging to someone suspected of being a terrorist?
*Q28 Should the government shut down social media accounts belonging to someone suspected of being an Islamic Fundamentalist terrorist?
*Q34 Should the government shut down social media accounts belonging to someone suspected of being a White Nationalist terrorist?
*1= yes
*0= no

tab Q22
tab Q28
tab Q34

gen socialmed=.
replace socialmed=1 if Q22==1
replace socialmed=1 if Q28==1
replace socialmed=1 if Q34==1
replace socialmed=0 if Q22==0
replace socialmed=0 if Q28==0
replace socialmed=0 if Q34==0
tab socialmed
tab socialmed
label define socialmed 0 "No" 1 "Yes"
label values socialmed socialmed
tab socialmed

**Info for Table 4
*Dem
tab socialmed terror if(party2==0), col
prtest socialmed if(terror==0 & party2==0 | terror==1 & party2==0), by(terror)
prtest socialmed if(terror==0 & party2==0 | terror==2 & party2==0), by(terror)
*Rep
tab socialmed terror if(party2==1), col
prtest socialmed if(terror==0 & party2==1 | terror==1 & party2==1), by(terror)
prtest socialmed if(terror==0 & party2==1 | terror==2 & party2==1), by(terror)
*Full Model for Supplementals
logit socialmed i.terror i.party2 i.gender2 i.race3 edu age income WNthreat IFthreat  i.terror##i.party2, robust
*outreg2 using ModelsDi.doc, append ctitle(Social Media) label 
margins, dydx(i.terror) at(party2=(0 1)) vsquish
marginsplot, scheme(s1mono)  xlab(-.25 " " 0 "Democrat" 1 "Republican" 1.25 " ", ) title("Effect on Prob. of Support for Shutting Down Social Media (Dynata 2)") yline(0,lpattern(dot))  xtitle("Partisanship", margin(medium)) ytitle("Effect on Probability of Support", margin(medium)) plot(,label("Islamic Fundamentalist" "White Nationalist"))
*graph export MediaParty.pdf, replace
*Predicted Probabilities for Table 4
margins i.terror, at(party2=(0 1)) vsquish

*HOLD
*Q24 Should the government be allowed to hold a person suspected of plotting a terror attack for an unlimited amount of time?
*Q30 Should the government be allowed to hold an Islamic Fundamentalist suspected of plotting a terror attack for an unlimited amount of time?
*Q36 Should the government be allowed to hold a White Nationalist suspected of plotting a terror attack for an unlimited amount of time?
*1= yes
*0= no

tab Q24
tab Q30
tab Q36

gen hold=.
replace hold=1 if Q24==1
replace hold=1 if Q30==1
replace hold=1 if Q36==1
replace hold=0 if Q24==0
replace hold=0 if Q30==0
replace hold=0 if Q36==0
tab hold
label define hold 0 "No" 1 "Yes"
label values hold hold
tab hold

**Info for Table 4
*Dem
tab hold terror if(party2==0), col
prtest hold if(terror==0 & party2==0 | terror==1 & party2==0), by(terror)
prtest hold if(terror==0 & party2==0 | terror==2 & party2==0), by(terror)
*Rep
tab hold terror if(party2==1), col
prtest hold if(terror==0 & party2==1 | terror==1 & party2==1), by(terror)
prtest hold if(terror==0 & party2==1 | terror==2 & party2==1), by(terror)
*Full Model for Supplementals
logit hold i.terror i.party2 i.gender2 i.race3 edu age income WNthreat IFthreat  i.terror##i.party2, robust
*outreg2 using ModelsDi.doc, append ctitle(hold) label 
margins, dydx(i.terror) at(party2=(0 1)) vsquish
marginsplot, scheme(s1mono)  xlab(-.25 " " 0 "Democrat" 1 "Republican" 1.25 " ", ) title("Effect on Prob. of Support for Holding Indefinitely (Dynata 2)") yline(0,lpattern(dot))  xtitle("Partisanship", margin(medium)) ytitle("Effect on Probability of Support", margin(medium)) plot(,label("Islamic Fundamentalist" "White Nationalist"))
*graph export HoldParty.pdf, replace
*Predicted Probabilities for Table 4
margins i.terror, at(party2=(0 1)) vsquish


***** 4 item index
tab speech
tab monitor
tab socialmed
tab hold

gen addindex= speech + monitor + socialmed + hold
tab addindex

gen avgindex= addindex/4
tab avgindex

**Info for Table 4
*Dem
tabstat avgindex if(party2==0), by(terror) stats(mean sem n)
ttest avgindex if(terror==0 & party2==0 | terror==1 & party2==0), by(terror)
ttest avgindex  if(terror==0 & party2==0 | terror==2 & party2==0), by(terror)
*Rep
tabstat avgindex if(party2==1), by(terror) stats(mean sem n)
ttest avgindex if(terror==0 & party2==1 | terror==1 & party2==1), by(terror)
ttest avgindex  if(terror==0 & party2==1 | terror==2 & party2==1), by(terror)
*Full Model for Table 2 and Supplementals
regress avgindex i.terror i.party2 i.gender2 i.race3 edu age income WNthreat IFthreat  i.terror##i.party2, robust
*outreg2 using ModelsDi.doc, append ctitle(Index) label 
*Figure 3
margins, dydx(i.terror) at(party2=(0 1)) vsquish
marginsplot, scheme(s1mono)  xlab(-.25 " " 0 "Democrat" 1 "Republican" 1.25 " ", ) title("Effect on Support for Restrictions (Index, Dynata 2)") yline(0,lpattern(dot))  xtitle("Partisanship", margin(medium)) ytitle("Effect on Support for Restrictions", margin(medium)) plot(,label("Islamic Fundamentalist" "White Nationalist"))
*graph export AverageIndex.pdf, replace

margins i.terror, at(party2=(0 1)) vsquish



**************************************
*Analyses for Supplemental Materials**
**************************************

*Models with no controls (still interacting party and treatment)
logit speech i.terror i.party2 i.terror##i.party2, robust
*outreg2 using NoControlModels.doc, replace ctitle(Ban Speech) label
logit monitor i.terror i.party2  i.terror##i.party2
*outreg2 using NoControlModels.doc, append ctitle(Monitor) label
logit socialmed i.terror i.party2  i.terror##i.party2
*outreg2 using NoControlModels.doc, append ctitle(Social Media) label
logit hold i.terror i.party2  i.terror##i.party2
*outreg2 using NoControlModels.doc, append ctitle(Hold) label
regress avgindex i.terror i.party2  i.terror##i.party2, robust
*outreg2 using NoControlModels.doc, append ctitle(Index) label

*Full Models (with controls) with partisanship as 3 categories: Democrat, “Pure” Independent, Republican.
logit speech i.terror i.party3 i.gender2 i.race3 edu age income WNthreat IFthreat  i.terror##i.party3, robust
*outreg2 using ModelsParty3.doc, replace ctitle(Ban Speech) label 
logit monitor i.terror i.party3 i.gender2 i.race3 edu age income WNthreat IFthreat  i.terror##i.party3, robust
*outreg2 using ModelsParty3.doc, append ctitle(Monitor) label 
logit socialmed i.terror i.party3 i.gender2 i.race3 edu age income WNthreat IFthreat  i.terror##i.party3, robust
*outreg2 using ModelsParty3.doc, append ctitle(SocialMedia) label 
logit hold i.terror i.party3 i.gender2 i.race3 edu age income WNthreat IFthreat  i.terror##i.party3, robust
*outreg2 using ModelsParty3.doc, append ctitle(Hold) label 
regress avgindex i.terror i.party3 i.gender2 i.race3 edu age income WNthreat IFthreat  i.terror##i.party3, robust
*outreg2 using ModelsParty3.doc, append ctitle(Index) label 

*Models with no controls or interactions for party; just average treatment effects
logit speech i.terror, robust
*outreg2 using ATEModels.doc, replace ctitle(Ban Speech) label
logit monitor i.terror, robust
*outreg2 using ATEModels.doc, append ctitle(Monitor) label 
logit socialmed i.terror, robust
*outreg2 using ATEModels.doc, append ctitle(Social Media) label 
logit hold i.terror, robust
*outreg2 using ATEModels.doc, append ctitle(Hold) label
regress avgindex i.terror, robust
*outreg2 using ATEModels.doc, append ctitle(Index) label

***Models to be corrected for multiple group comparisons
regress avgindex i.terror i.party2  i.terror##i.party2, robust pformat(%5.4f) 
regress avgindex i.terror i.party2 i.gender2 i.race3 edu age income WNthreat IFthreat  i.terror##i.party2, robust pformat(%5.4f) 





